package com.hq.fxh.No6UerSpace.Adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.hq.fxh.Modle.UserVideoModle;
import com.hq.fxh.R;
import com.hq.fxh.Utils.AppConstant;
import com.hq.fxh.Utils.GlideUtils;
import com.hq.fxh.Utils.Tool;

import java.util.List;

/**
 * /**
 *
 * @author 薛
 * @ClassName
 * @Description :
 * @Created 2017/9/19
 * @Email xlwenhao1858@sina.com
 */


public class Radapter_UserSpace_Video extends RecyclerView.Adapter<Radapter_UserSpace_Video.PlateViewHolder> {

    List<UserVideoModle> vdioeData;
    Context context;

    public void setVdioeData(List<UserVideoModle> vdioeData) {
        this.vdioeData = vdioeData;
    }

    @Override
    public PlateViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        if (context == null) {
            context = parent.getContext();

        }


        PlateViewHolder plateViewHolder = new PlateViewHolder(View.inflate(context, R.layout.item_myplate_video, null));

        return plateViewHolder;
    }

    @Override
    public void onBindViewHolder(PlateViewHolder holder, int position) {

        UserVideoModle userVideoModle = vdioeData.get(position);
        String subject_img_url = userVideoModle.getSubject_img_url();

        Tool.setUrlToImage(context, subject_img_url, holder.videoListImage);
        Tool.setStringToText(holder.videoFragmentTime, userVideoModle.getSubject_item_count());
        Tool.setStringToText(holder.videoFragmentNum, userVideoModle.getAction_num() + "");

    }

    @Override
    public int getItemViewType(int position) {
        if (position % 2 == 0) {

            return 1;
        } else {
            return 0;
        }
    }

    @Override
    public int getItemCount() {
        return vdioeData == null ? 0 : vdioeData.size();
    }


    class PlateViewHolder extends RecyclerView.ViewHolder {
        protected View rootView;
        protected TextView videoFragmentVideoName;
        protected ImageView videoListImageBg;
        protected ImageView videoListImage;
        protected TextView videoFragmentNum;
        protected TextView videoFragmentTime;

        public PlateViewHolder(View itemView) {
            super(itemView);
            initView(itemView);
        }


        private void initView(View rootView) {
            videoFragmentVideoName = (TextView) rootView.findViewById(R.id.videoFragment_videoName);
            videoListImageBg = (ImageView) rootView.findViewById(R.id.videoList_Image_bg);
            videoListImage = (ImageView) rootView.findViewById(R.id.videoList_Image);
            videoFragmentNum = (TextView) rootView.findViewById(R.id.videoFragment_Num);
            videoFragmentTime = (TextView) rootView.findViewById(R.id.videoFragment_Time);

        }
    }


}
